<%@page import="conexao.Connect"%>
<html>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%
	
	boolean ok = false;	
	
	String Con_host = (String)request.getSession().getAttribute("Con_host");
	if (Con_host != null){
		String Con_database = (String) request.getSession().getAttribute("Con_database");
		String Con_usuario = (String) request.getSession().getAttribute("Con_usuario");
		String Con_senha = (String) request.getSession().getAttribute("Con_senha");
		
		Connect.updateConnection(Con_host,Con_database,Con_usuario,Con_senha);
		try{
			Connect.testConnection(request);
			ok = true;
		}catch(Exception ex){		
			//to-do
		}
	}	
	

	if (!ok){
		String host = config.getInitParameter("hostbd");
		String database = config.getInitParameter("databasebd");
		String usuariobd = config.getInitParameter("usuariobd");
		String senhabd = config.getInitParameter("senhabd");
	
		Connect.updateConnection(host,database,usuariobd,senhabd);
		try{
			Connect.testConnection(request);
		}catch(Exception ex){
			response.sendRedirect("index.jsp");
		}	
	}


	String empresa = (String) session.getAttribute("empresa");
	String modulo = (String) session.getAttribute("modulo");
	String esquema = (String) session.getAttribute("esquema");
	if (esquema == null) {
		esquema = "branco";
	}

	String esquemacss = (String) session.getAttribute("esquemacss");
	if (esquemacss == null) {
		esquemacss = "branco_S";
	}
	
	if (empresa == null) {
		empresa = " ";
	}

	if (modulo == null) {
		modulo = " ";
	}
		
%>
<head>
<link href="css/estilo.css" rel="stylesheet" type="text/css">
<link href="css/<%=esquemacss%>.css" rel="stylesheet" type="text/css" />
<link REL="SHORTCUT ICON" HREF="images/esquema/<%=esquema%>/favicon.ico" type="image/x-icon" />
<link REL="ICON" HREF="images/esquema/<%=esquema%>/favicon.ico" type="image/x-icon" />

</head>
<body>
<div class="divbotoes">
<table id="tb-logo" class="tbbotoes" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>		
	<td width="80" height="40px"><input name="Button" id="Novo" value="Novo" type="button" class="btnovo"
		style="width: 135px; height: 39px;" onclick="formAjax.enviasubmit('Novo');"></td>
  </tr>		
  <tr>		
	<td width="80" height="40px"><input name="Button" id="pesquisar" value="F2-Buscar" type="button" class="btpesquisa"
	    style="width: 135px; height: 39px;" onclick="formAjax.envia('true','Pesquisar','false','true','false');"></td>
  </tr>
  <tr>		
	<td width="80" height="40px"><input name="Button" id="imprimir" value="Imprimir" type="button" class="btimprimir"
	    style="width: 135px; height: 39px;" onclick="formAjax.envia('true','Imprimir','false','true','false');"></td>
  </tr>		
  <tr>		
    <td>
      <table id="tbmsm" width="100%" height="100%" class="tbmsm1">
	    <tr>
	     <td height="85px" width="40px">
 	       <div id="msmico" class="imgicomsm"></div>
         <td>
  	       <div id="menssagem" class="stylemsm"></div>		     
	     </td>
	    </tr>	      
      </table>
	</td>	
  </tr>
</table>

</div>
</body>
</html>
